<template>
  <div class="mian-dialog" :id="domId" :style="{
    '--during': during,
    '--positionTop': positionTop+'px',
    '--positionLeft': positionLeft+'px',
  }">
    <div class="title">
      <span>
        {{ dataOption.title }}
      </span>
      <span class="delete-project" @click.stop="closeHanlder">x</span>
    </div>
    <div class="content">
      <div class="content-item" @click="choiceHanlder('left')">左</div>
      <div class="content-item" @click="choiceHanlder('right')">右</div>
      <div class="content-item" @click="choiceHanlder('all')">全部</div>
    </div>
  </div>
</template>
<script>
import removeDom from "./utils/removeDom";
export default {
  name: 'CustomPopups',
  data() {
    return {
      domId: null,
      isClose: false,
      during: 200,
      positionTop: 0,
      positionLeft: 0
    };
  },
  props: {},
  components: {},
  created() {
    this.positionTop = this.dataOption.position.top
    this.positionLeft = this.dataOption.position.left
    this.domId = this.dialogOptions.domId;
    this.during = this.dialogOptions.during ? this.dialogOptions.during : 100
  },
  methods: {
    choiceHanlder(key){
      this.dataOption.callback(key).then(()=> {
        this.closeHanlder()
      })
    },
    closeHanlder() {
      this.isClose = true
      this.$nextTick(() => {
        setTimeout(() => {
          removeDom(this.domId);
        }, this.during)
      })
    },
  },
};
</script>
<style scoped>
.mian-dialog {
  background: #fafafa;
  box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
  width: 150px;
  height: 300px;
  position: absolute;
  top: var(--positionTop);
  left: var(--positionLeft);
  font-size: 14px;
  border-radius: 10px;
  padding: 10px;
}
.content {
  height: 250px;
  padding: 15px;
}
.content-item:hover{
  background: #f0f0f0;
  cursor: pointer;
}
.delete-project {
  float: right;
  padding: 3px 0;
  cursor: pointer;
}

.delete-project:hover {
  color: #409eff;
}

.fadeOut {
  animation: slide-out-top var(--during) cubic-bezier(0.550, 0.085, 0.680, 0.530) both;
}

@keyframes slide-out-top {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}
</style>
